package com.PAT.UnSatisfying;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: zjz
 * @Date: 2022/02/19/9:33
 * @Description:
 * @Target: 差3
 */
public class 矩阵行平移 {
    // 输入n*n的矩阵,k,替换的数
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String ss1 = in.nextLine();
        int n = Integer.valueOf(ss1.split(" ")[0]);
        int k = Integer.valueOf(ss1.split(" ")[1]);
        int x = Integer.valueOf(ss1.split(" ")[2]);

        int[][] ints = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                ints[i][j] = in.nextInt();
            }
        }

        int count = 1;
        String[] strings = new String[n];
        int[] countSum = new int[n];

        for (int i = 0; i < n; i++) {
            String tempString = "" ;
            if (i%2==0){
                for (int j = 0; j < count; j++) {
                    tempString += x+" ";
                }
                for (int j = 0; j < n-count; j++) {
                    if (j==n-count-1){
                        tempString += ints[i][j];
                    }else {
                        tempString += ints[i][j]+ " ";
                    }
                }
                if (count<k){
                    count++;
                }else {
                    count = 1;
                }
            }else {
                for (int j = 0; j < n; j++) {
                    if (j==n-1){
                        tempString += ints[i][j];
                    }else {
                        tempString += ints[i][j]+ " ";
                    }
                }
            }

            strings[i] = tempString;
        }


        for (String string : strings) {
            for (int i = 0; i < n; i++) {
                countSum[i]+=Integer.valueOf(string.split(" ")[i]);
            }
        }

        for (int i = 0; i < countSum.length; i++) {
            if (i==countSum.length-1){
                System.out.print(countSum[i]);
            }else {
                System.out.print(countSum[i]+" ");
            }
        }
    }
}
